package com.windoent.yugioh.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.windoent.yugioh.R;

/**
 * author : robert
 * date   : 2021/4/28 11:23
 * desc   :
 */
public class ActivityTitle extends RelativeLayout {
    private Context mConText;
    private View mView;
    private ActivityBackLeft mBack;
    private TextView mTvTitle;
    private String tvhint;


    public ActivityTitle(Context context) {
        this(context, null, 0);
    }

    public ActivityTitle(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ActivityTitle(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mConText = context;
        LayoutInflater.from(mConText).inflate(R.layout.custom_view_activity_title, this);
        TypedArray attributes = mConText.obtainStyledAttributes(attrs, R.styleable.UserInfoItem, 0, 0);
        try {
            tvhint = attributes.getString(R.styleable.UserInfoItem_tvhint);
        } finally {
            attributes.recycle();
        }
        setUpView();
    }

    private void setUpView() {

        mView = (View) findViewById(R.id.view);
        mBack = (ActivityBackLeft) findViewById(R.id.back);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mTvTitle.setText(tvhint);

    }

    public void setTvTitle(String s) {
        mTvTitle.setText(s);
    }

    public void setBackListener(OnClickListener listener) {
        mBack.setBackListener(listener);
    }

    public View getView() {
        return mView;
    }
}
